<template>
	<view class="page">
		<!--标题-->
		<view class='page__hd'>
			<view class="page__title">
				{{index+1}}、{{questionList[index].question}}
				{{questionList[index].questionType==1||questionList[index].questionType==3?"【单选】":"【多选】"}}
				（{{questionList[index].scores}}分）
			</view>
		</view>
		<!--内容-->
 		<view class="page__bd">
	    <radio-group class="radio-group" @change="radioChange" v-if="questionList[index].questionType == '1'">
	      <label class="radio my-choosebox" v-for="(p, index) in questionList[index].questionOption">
	        <radio value="index" checked="questionList[index].checked"/>{{index}}、{{p}}
	      </label>
	    </radio-group>
<!-- 	    <checkbox-group bindchange="checkboxChange" wx:elif="{{questionList[index-1].type == 2}}">
	      <label class="checkbox my-choosebox" wx:for="{{questionList[index-1].option}}" wx:for-index="key"  wx:for-item="value">
	        <checkbox value="{{key}}" checked="{{questionList[index-1].checked}}"/>{{key}}、{{value}}
	      </label>
	    </checkbox-group>
	    <radio-group class="radio-group" bindchange="radioChange" wx:else>
	      <label class="radio my-choosebox" wx:for="{{questionList[index-1].option}}">
	        <radio value="{{item}}" checked="{{questionList[index-1].checked}}"/>{{item}}
	      </label>
	    </radio-group> -->
	  </view>
		<!--按钮-->
		<!-- 	  <view class='page_ft'>
	    <view class='mybutton'>
	      <button bindtap='nextSubmit' wx:if="{{index == questionList.length}}">提交</button>
	      <button bindtap='nextSubmit' wx:else>下一题</button>
	      <text bindtap='outTest' class="toindex-btn">退出答题</text>
	    </view>
	  </view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				questionList: [],
				index:0,
			}
		},
		onShow(){
			try{
				this.getQuestionList()
				
			} catch(e){
				
			}
		},
		methods: {
			getQuestionList() {
				console.log("开始——获取党史题库")
				uni.request({
					url: this.websiteUrl + '/dang/question', //获取前三名成绩
					success: (res) => {
						console.log("成功——获取党史题库:" + res.data.data[0].questionOption);
						this.questionList = res.data.data;
					}
				});
			},
			  /*
			  * 单选事件
			  */
			  radioChange: function (e) {
			    console.log('checkbox发生change事件，携带value值为：', e.detail.value)
			    this.data.chooseValue[this.data.index] = e.detail.value;
			    console.log(this.data.chooseValue);
			  },

		}
	}
</script>

<style lang="scss">
	.page {
		padding: 20rpx;
	}

	.page__bd {
		padding: 20rpx;
	}

	.my-choosebox {
		display: block;
		margin-bottom: 20rpx;
	}

	.toindex-btn {
		margin-top: 20rpx;
		display: inline-block;
		line-height: 2.3;
		font-size: 13px;
		padding: 0 1.34em;
		color: #576b95;
		text-decoration: underline;
		float: right;
	}
</style>
